<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../../../lib/layui-v2.6.3/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->

    <script src="../../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
    <script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>

    <script src="../../../lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>


    <script src="../../../js/echarts.min.js"></script>
</head>

<body>
    <div id="main" style="width: 600px;height:400px;"></div>
    <script type="text/javascript">
        var chartDom = document.getElementById('main');


        var myChart = echarts.init(chartDom);
        var option;
        var data1 = [];
        var data2 = [];

        $.ajax({

            url: "http://localhost:8080/household/echarts1",
            data: "",
            dataType: "json",
            success: function (res) {

                if (res.code == 0) {

                    debugger
                    $.each(res.data.householdVoList, function (index, n) {
                        data1.push(res.data.householdVoList[index].household_name);
                        data2.push(res.data.householdVoList[index].household_price);
                    });


                    option = {
                        xAxis: {
                            type: 'category',
                            data: data1
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [
                            {
                                data: data2,
                                type: 'line',
                                smooth: true
                            }
                        ]
                    };

                    option && myChart.setOption(option);


                } else {

                }
            }


        });





    </script>


</body>

</html>